﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Apewer.Internals.Interop
{

    internal class SHCore
    {

        /// <summary>Retrieves the dots per inch (dpi) awareness of the specified process.</summary>
        /// <param name="hprocess">Handle of the process that is being queried. If this parameter is NULL, the current process is queried.</param>
        /// <param name="awareness">The DPI awareness of the specified process. Possible values are from the PROCESS_DPI_AWARENESS enumeration.</param>
        /// <remarks>最小支持 Windows 8.1 及 Windows Server 2012 R2。</remarks>
        [DllImport("SHCore.dll", SetLastError = true)]
        public static extern void GetProcessDpiAwareness(IntPtr hprocess, out PROCESS_DPI_AWARENESS awareness);

        [DllImport("SHCore.dll", SetLastError = true)]
        public static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness);

        public enum PROCESS_DPI_AWARENESS
        {

            /// <summary>DPI unaware.<br />
            /// This app does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).<br />
            /// It will be automatically scaled by the system on any other DPI setting.</summary>
            Process_DPI_Unaware = 0,

            /// <summary>System DPI aware.<br />
            /// This app does not scale for DPI changes.<br />
            /// It will query for the DPI once and use that value for the lifetime of the app.<br />
            /// If the DPI changes, the app will not adjust to the new DPI value.<br />
            /// It will be automatically scaled up or down by the system when the DPI changes from the system value.</summary>
            Process_System_DPI_Aware = 1,

            /// <summary>Per monitor DPI aware.<br />
            /// This app checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.<br />
            /// These applications are not automatically scaled by the system.</summary>
            Process_Per_Monitor_DPI_Aware = 2

        }

    }

}
